﻿using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace SignatureWebApi.Models
{
    // 用作 AccountController 操作的参数的模型。

    public class AddExternalLoginBindingModel
    {
        [Required]
        [Display(Name = "外部访问令牌")]
        public string ExternalAccessToken { get; set; }
    }

    public class ChangePasswordBindingModel
    {
        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "当前密码")]
        public string OldPassword { get; set; }

        [Required]
        [StringLength(100, ErrorMessage = "{0} 必须至少包含 {2} 个字符。", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "新密码")]
        public string NewPassword { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "确认新密码")]
        [Compare("NewPassword", ErrorMessage = "新密码和确认密码不匹配。")]
        public string ConfirmPassword { get; set; }
    }

    public class RegisterBindingModel
    {
        [Required]
        [Display(Name = "用户名")]
        public string UserName { get; set; }

        [Required]
        [StringLength(100, ErrorMessage = "{0} 必须至少包含 {2} 个字符。", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "密码")]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "确认密码")]
        [Compare("Password", ErrorMessage = "密码和确认密码不匹配。")]
        public string ConfirmPassword { get; set; }

        [Display(Name = "用户真名")]
        public string RealName { get; set; }
    }
    public class LoginBindingModel
    {
        [Required]
        [Display(Name = "用户名")]
        public string UserName { get; set; }

        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "密码")]
        public string Password { get; set; }

    }

    public class RegisterExternalBindingModel
    {
        [Required]
        [Display(Name = "电子邮件")]
        public string Email { get; set; }
    }

    public class RemoveLoginBindingModel
    {
        [Required]
        [Display(Name = "登录提供程序")]
        public string LoginProvider { get; set; }

        [Required]
        [Display(Name = "提供程序密钥")]
        public string ProviderKey { get; set; }
    }

    /// <summary>
    /// 设置密码模型
    /// </summary>
    public class SetPasswordBindingModel
    {
        [Required]
        public string UserName { get; set; }
        [Required]
        [StringLength(100, ErrorMessage = "{0} 必须至少包含 {2} 个字符。", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "新密码")]
        public string NewPassword { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "确认新密码")]
        [Compare("NewPassword", ErrorMessage = "新密码和确认密码不匹配。")]
        public string ConfirmPassword { get; set; }
    }

    /// <summary>
    /// 角色绑定模型
    /// </summary>
    public class ControlRolesBindingModel
    {
        /// <summary>
        /// 用户名
        /// </summary>
        [Required]
        public string UserName { get; set; }
        /// <summary>
        /// 角色
        /// </summary>
        [Required]
        public string[] Roles { get; set; }

    }

    /// <summary>
    /// 查询用户角色返回模型
    /// </summary>
    public class UserRolesReturnModel
    {
        /// <summary>
        /// 该用户拥有的权限角色
        /// </summary>
        public IList<string> Roles { get; set; }
    }

    /// <summary>
    /// 用户声明模型
    /// </summary>
    public class UserClaimBindingModel
    {
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 声明类型
        /// </summary>
        public string ClaimType { get; set; }
        /// <summary>
        /// 声明值
        /// </summary>
        public string ClaimValue { get; set;}
    }

    /// <summary>
    /// 获取AcessToken的请求模型
    /// </summary>
    public class GetTokenModel
    {
        /// <summary>
        /// 
        /// </summary>
        public enum GrantType
        {
            /// <summary>
            /// 密码模式
            /// </summary>
            password,
            /// <summary>
            /// refreshToken模式
            /// </summary>
            refresh_token,
            /// <summary>
            /// 客户端认证模式
            /// </summary>
            client_credentials,
        }

        /// <summary>
        /// 认证模式(请求时请使用字符串否则会请求失败)
        /// </summary>
        public GrantType grant_type;

        /// <summary>
        /// 固定的ClientId
        /// </summary>
        public string client_id;

        /// <summary>
        /// 固定的Client_Secret
        /// </summary>
        public string client_secret;

        /// <summary>
        /// 当模式为password时的用户名
        /// </summary>
        public string userName;

        /// <summary>
        /// 当模式为password时的密码
        /// </summary>
        public string Password;


        /// <summary>
        /// 模式为refresh时发送的refreshtoken
        /// </summary>
        public string refresh_token;
    }

    /// <summary>
    /// Token模型
    /// </summary>
    public class TokenModel
    {
        /// <summary>
        /// accesstoken
        /// </summary>
        public string access_token = "UVN93ViMzyaBFXDbj4CRRLCaxXGdcCEavT";
        /// <summary>
        /// 认证类型
        /// </summary>
        public string token_type = "bearer";
        /// <summary>
        /// 认证过期时长
        /// </summary>
        public int expires_in = 86399;
        /// <summary>
        /// refreshtoken
        /// </summary>
        public string refresh_token = "UVN93ViMzyaBFXDbj4CRRLCaxXGdcCEavT";
        /// <summary>
        /// 用户登录名
        /// </summary>
        public string userName = "LiuJun";
        /// <summary>
        /// 用户真名
        /// </summary>
        public string realName = "刘峻";
        /// <summary>
        /// 认证日期
        /// </summary>
        public string issued = "Mon, 21 May 2018 02:58:10 GMT";
        /// <summary>
        /// 过期日期
        /// </summary>
        public string expires= "Mon, 21 May 2018 02:58:10 GMT";
    }
}
